package com.example.hp.yuejian5.model;

import com.example.hp.yuejian5.RetrofitListener.RetrofitListener;
import com.example.hp.yuejian5.bean.ActivityorderBean;
import com.example.hp.yuejian5.service.ActivityorderService;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

import static com.example.hp.yuejian5.other.url.ACTIVITYURL;

public class ActivityorderModel {
    protected Retrofit retrofit;
    protected ActivityorderService orderService;
    public ActivityorderModel()
    {
        retrofit=new Retrofit.Builder()
                .baseUrl(ACTIVITYURL)
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        orderService=retrofit.create(ActivityorderService.class);
    }
    public void Activityorder(String user_id,String activity_id,String realname,String tel,String anum,String snum,String card,String mode,String check,final RetrofitListener listener)
    {

        Call<ActivityorderBean> call= orderService.activityorder(user_id,activity_id,realname,tel,anum,snum,card,mode,check);
        call.enqueue(new Callback<ActivityorderBean>() {
            @Override
            public void onResponse(Call<ActivityorderBean> call, Response<ActivityorderBean> response) {
                listener.onSuccess(response.body(),1);
            }
            @Override
            public void onFailure(Call<ActivityorderBean> call, Throwable t) {
                listener.onFail();
            }
        });
    }

}
